<?php

require_once '../conexion.php';

class listAdm {

    private $conx;
    private $table;
    private $listrace = "SELECT * FROM RACE";
    private $listfood = "SELECT * FROM FOOD";
    private $listdisease = "SELECT * FROM DISEASE";

    public function __construct() {
        $this->conx = null;
    }

    public function listRace() {
        $this->table = "";
        $consult = sprintf($this->listrace);
        $this->conx = new conexion();
        $result = pg_exec($this->conx->getConexionDB(), $consult);
        $this->conx->closeConexionDB();
        $this->conx = null;
        $row = pg_num_rows($result);
        if ($row == 0) {
            $this->table .= "<td>No se Encuentran Razas</td>";
        } else {
            while ($rows = pg_fetch_array($result)) {
                $this->table .= "<tr>";
                $this->table .= "<td>{$rows['namerace']}</td>";
                $this->table .= "<td>{$rows['weightbirth']}</td>";
                $this->table .= "<td>{$rows['weightweaning']}</td>"; 
                $this->table .= "<td>{$rows['ageweaning']}</td>";
                $this->table .= "<td>{$rows['weightsacr']}</td>";
                $this->table .= "<td>{$rows['agesacr']}</td>";
                $this->table .= "<td>{$rows['canalperformance']}</td>";
                $this->table .= "<td>{$rows['weightcanal']}</td>";
                $this->table .= "</tr>";
            }
        }
        return $this->table;
    }
    
    public function listFood(){
        $this->table = "";
        $consult = sprintf($this->listfood);
        $this->conx = new conexion();
        $result = pg_exec($this->conx->getConexionDB(), $consult);
        $this->conx->closeConexionDB();
        $this->conx = null;
        $row = pg_num_rows($result);
        if ($row == 0) {
            $this->table .= "<td>No se Encuentran Pastos</td>";
        } else {
            while ($rows = pg_fetch_array($result)) {
                $this->table .= "<tr>";
                $this->table .= "<td>{$rows['namefood']}</td>";
                $this->table .= "<td>{$rows['drymatter']}</td>";
                $this->table .= "<td>{$rows['crudeprotein']}</td>"; 
                $this->table .= "<td>{$rows['ndt']}</td>";
                $this->table .= "<td>{$rows['em']}</td>";
                $this->table .= "<td>{$rows['enm']}</td>";
                $this->table .= "<td>{$rows['eng']}</td>";
                $this->table .= "<td>{$rows['ca']}</td>";
                $this->table .= "<td>{$rows['p']}</td>";
                $this->table .= "</tr>";
            }
        }
        return $this->table;
    }
    
    public function listDiseaseAdm(){
        $this->table = "";
        $consult = sprintf($this->listdisease);
        $this->conx = new conexion();
        $result = pg_exec($this->conx->getConexionDB(), $consult);
        $this->conx->closeConexionDB();
        $this->conx = null;
        $row = pg_num_rows($result);
        if ($row == 0) {
            $this->table .= "<td>No se Encuentran Enfermedades</td>";
        } else {
            while ($rows = pg_fetch_array($result)) {
                $this->table .= "<tr>";
                $this->table .= "<td>{$rows['diseasename']}</td>";
                $this->table .= "<td>{$rows['symptom']}</td>";
                $this->table .= "<td>{$rows['tratamient']}</td>";
                $this->table .= "</tr>";
            }
        }
        return $this->table;
    }

}

?>
